import { encrypt, decrypt } from '@/utils/sm4.js'
import { key } from '@/settings.js'

/**
 * AES加密 ：字符串 key  返回base64
 */
export function Encrypt(word) {
  if (!word) return ''
  return encrypt(JSON.stringify(word), key)
}
/**
 * AES 解密 ：字符串 key  返回base64
 *
 */
export function Decrypt(word) {
  const str = decrypt(word, key)
  let dWord = ''
  try {
    dWord = JSON.parse(str)
  } catch (err) {
    dWord = str
  }
  return dWord
}
